<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>组合继承-两种方式组合在一起来完成继承，call(apply)用来继承构造函数+原型对象</p>

    <script>
        function Person(w) {
            this.head = 1;
            this.foots = 2;
            this.weight = w;
            this.say = function () {
                console.log('我有' + this.head + '个头，还有' + this.foots + '个🦶🏻，有趣的灵魂，' + this.weight + 'kg');
            }
        }
        Person.prototype.eat = function () {
            console.log('中午吃啥？');
        }
        Person.prototype.eat1 = function () {
            console.log('中午吃啥？');
        }
        Person.prototype.eat2 = function () {
            console.log('中午吃啥？');
        }
        Person.prototype.eat3 = function () {
            console.log('中午吃啥？');
        }

        // ================
        function Student(name, no, weight) {
            // 构造函数的继承
            Person.call(this, weight); // 这一步完成后有了头、🦶🏻、体重、会说话
            this.name = name;
            this.no = no;
        }

        Student.prototype = new Person(50); // 为了得到Person的prototype上的各个方法
        Student.prototype.constructor=Student;// 纠正继承关系

        var s1 = new Student('子路', 2, 180);
        console.log(s1);
    </script>
</body>

</html>